﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace WindowsFormsApplication1.wtyczki
{
    static class GrayScale
    {
        public static Bitmap toGray(Bitmap bm)
        {
            Bitmap bmTmp = new Bitmap(bm);
            for (int y = 1; y < bm.Height; y++)
            {
                for (int x = 1; x < bm.Width; x++)
                {
                    int color= (bm.GetPixel(x, y).R+bm.GetPixel(x, y).G+ bm.GetPixel(x, y).B)/3;
                    bmTmp.SetPixel(x, y, Color.FromArgb(color,color,color));
                }
            }
            return bmTmp;
        }

    }
}
